** Cleaning MTurk/Conjoint Data
** This data has been anonymized by removing Amazon identifiers, IP addresses,
** and similar data from this distribution file, per our IRB protocol.

/*
There is not much commentary here because this is essentially a backend, clerical
document meant to take a lump of raw data and transform it into useful versions
for analysis. 
*/

*********************
* Stata preliminaries
*********************


version 14
clear all
set more off

global path "~/Dropbox/0001 Academic Projects/Ongoing/0148 The Cyber/Posted/FPA Version/Work"

cd "$path/Raw/"
import delimited TheCyber2019MergedDataNoHeadersAnonymized.csv,clear

gen wave1age = 2019-wave1q4

gen wave1female = .
replace wave1female = 1 if wave1q5 == "Female"
replace wave1female = 0 if wave1q5 == "Male"

gen wave1college = .
replace wave1college = 1 if wave1q9 == "Bachelor's degree (e.g. BA, BS)"
replace wave1college = 1 if wave1q9 == "Doctorate (e.g. PhD, EdD)"
replace wave1college = 1 if wave1q9 == "Master's degree (e.g. MA, MS, M.Ed.)"
replace wave1college = 1 if wave1q9 == "Professional degree (e.g. JD, MD, DDS)"

replace wave1college = 0 if wave1q9 == "Associate degree (e.g. AA, AS)"
replace wave1college = 0 if wave1q9 == "Less than a high school diploma"
replace wave1college = 0 if wave1q9 == "Some college, no degree"
replace wave1college = 0 if wave1q9 == "High school degree or equivalent (e.g., GED)"


gen wave2age = 2019-wave2q21

gen wave2female = .
replace wave2female = 1 if wave2q23 == "Female"
replace wave2female = 0 if wave2q23 == "Male"

gen wave2college = .
replace wave2college = 1 if wave2q22 == "Bachelor's degree (e.g. BA, BS)"
replace wave2college = 1 if wave2q22 == "Doctorate (e.g. PhD, EdD)"
replace wave2college = 1 if wave2q22 == "Master's degree (e.g. MA, MS, M.Ed.)"
replace wave2college = 1 if wave2q22 == "Professional degree (e.g. JD, MD, DDS)"

replace wave2college = 0 if wave2q22 == "Associate degree (e.g. AA, AS)"
replace wave2college = 0 if wave2q22 == "Less than a high school diploma"
replace wave2college = 0 if wave2q22 == "Some college, no degree"
replace wave2college = 0 if wave2q22 == "High school degree or equivalent (e.g., GED)"


gen agediff = wave2age-wave1age

gen degreematch = .
replace degreematch =1 if wave1q9 == wave2q22
replace degreematch =0 if wave1q9 != wave2q22 & wave2q22!=""

drop if degreematch == 0
drop if agediff != 0 & wave2age != .
drop if wave2female != wave1female  & wave2female != .

drop _merge degreematch agediff 

gen caseid = _n

order f*, last
rename wave1age age
rename wave1female female
rename wave1college college

gen white = 0
replace white = 1 if wave1q11=="White"&wave1q13=="No"

rename wave1q35_1 thermUSA
rename wave1q35_2 thermRUS
rename wave1q35_3 thermGBR
rename wave1q35_4 thermPRC
rename wave1q35_5 thermIND
rename wave1q35_6 thermFRA
rename wave1q35_7 thermPRK
rename wave1q35_8 thermDEU
rename wave1q35_9 thermJPN
rename wave1q35_10 thermIRN
rename wave1q35_11 thermISR
rename wave1q35_12 thermROK
rename wave1q35_13 thermVNM
rename wave1q35_14 thermCAN
rename wave1q35_15 thermBRA

******************

lab def criticallab 0 "Not Important" 1 "Important, not critical" 2 "Critical"

gen threatKorea = .
replace threatKorea = 0 if wave1q27_1 == "Not important"
replace threatKorea = 1 if wave1q27_1 == "Important, but not critical"
replace threatKorea = 2 if wave1q27_1 == "Critical threat"

gen threatCyber = .
replace threatCyber = 0 if wave1q27_2 == "Not important"
replace threatCyber = 1 if wave1q27_2 == "Important, but not critical"
replace threatCyber = 2 if wave1q27_2 == "Critical threat"

gen threatTerrorism = .
replace threatTerrorism = 0 if wave1q27_3 == "Not important"
replace threatTerrorism = 1 if wave1q27_3 == "Important, but not critical"
replace threatTerrorism = 2 if wave1q27_3 == "Critical threat"

gen threatIran = .
replace threatIran = 0 if wave1q27_4 == "Not important"
replace threatIran = 1 if wave1q27_4 == "Important, but not critical"
replace threatIran = 2 if wave1q27_4 == "Critical threat"

gen threatChina = .
replace threatChina = 0 if wave1q27_5 == "Not important"
replace threatChina = 1 if wave1q27_5 == "Important, but not critical"
replace threatChina = 2 if wave1q27_5 == "Critical threat"

gen threatFinancial = .
replace threatFinancial = 0 if wave1q27_6 == "Not important"
replace threatFinancial = 1 if wave1q27_6 == "Important, but not critical"
replace threatFinancial = 2 if wave1q27_6 == "Critical threat"

gen threatMuslim = .
replace threatMuslim = 0 if wave1q27_7 == "Not important"
replace threatMuslim = 1 if wave1q27_7 == "Important, but not critical"
replace threatMuslim = 2 if wave1q27_7 == "Critical threat"

gen threatRussia = .
replace threatRussia = 0 if wave1q27_8 == "Not important"
replace threatRussia = 1 if wave1q27_8 == "Important, but not critical"
replace threatRussia = 2 if wave1q27_8 == "Critical threat"

gen threatEbola = .
replace threatEbola = 0 if wave1q27_9 == "Not important"
replace threatEbola = 1 if wave1q27_9 == "Important, but not critical"
replace threatEbola = 2 if wave1q27_9 == "Critical threat"

gen threatRefugees = .
replace threatRefugees = 0 if wave1q27_10 == "Not important"
replace threatRefugees = 1 if wave1q27_10 == "Important, but not critical"
replace threatRefugees = 2 if wave1q27_10 == "Critical threat"

gen threatChinaNeighbor = .
replace threatChinaNeighbor = 0 if wave1q27_11 == "Not important"
replace threatChinaNeighbor = 1 if wave1q27_11 == "Important, but not critical"
replace threatChinaNeighbor = 2 if wave1q27_11 == "Critical threat"

gen threatClimate = .
replace threatClimate = 0 if wave1q27_12 == "Not important"
replace threatClimate = 1 if wave1q27_12 == "Important, but not critical"
replace threatClimate = 2 if wave1q27_12 == "Critical threat"

drop wave1q27_*

lab val threat* criticallab

******************

rename wave1q36_1 threatCyberRussia
rename wave1q36_2 threatCyberChina
rename wave1q36_3 threatCyberIran
rename wave1q36_4 threatCyberKorea
rename wave1q36_5 threatCyberCriminals
rename wave1q36_6 threatCyberCanada
rename wave1q36_7 threatCyberTerrorists

******************
gen cyberForeign = .
replace cyberForeign = 1 if wave1q28 == "Yes"
replace cyberForeign = 0 if wave1q28 == "No" | wave1q28 == "Not sure"
lab var cyberForeign "Think other countries disrupt US computers?"

gen cyberUSA = .
replace cyberUSA = 1 if wave1q29 == "Yes"
replace cyberUSA = 0 if wave1q29 == "No" | wave1q29 == "Not sure"
lab var cyberUSA "Think US government disrupts other countries' computers?"

drop wave1q29 wave1q28

*************************

gen cyberPersonal = .
replace cyberPersonal = 0 if wave1q30 == "Not at all worried"
replace cyberPersonal = 1 if wave1q30 == "Not very worried"
replace cyberPersonal = 2 if wave1q30 == "Somewhat worried"
replace cyberPersonal = 3 if wave1q30 == "Very worried"

lab var cyberPersonal "Worried about personal impact of attacks on computer systems"
lab def worried 0 "Not at all worried " 1 "Not very worried" ///
2 "Somewhat worried" 3 "Very worried"
lab val cyberPersonal worried
drop wave1q30

*************************


gen cyberPrepared = .
lab var cyberPrepared "How prepared do you think US is for major cyber-attack?"
lab def cyberprep 0 "Not prepared" 1 "Not too prepared" 2 "Somewhat prepared" 3 "Very prepared"

replace cyberPrepared = 0 if wave1q31 == "Not prepared"
replace cyberPrepared = 1 if wave1q31 == "Not too prepared"
replace cyberPrepared = 2 if wave1q31 == "Somewhat prepared"
replace cyberPrepared = 3 if wave1q31 == "Very prepared"

lab val cyberPrepared cyberprep

drop wave1q31

*************************


gen cyberMostResponsible = .
lab var cyberMostResponsible "Who bears responsibility for defending?"
replace cyberMostResponsible = 0 if wave1q32 == "Individuals and private businesses"
replace cyberMostResponsible = 1 if wave1q32 == "Internet service providers, like AT&T and Comcast"
replace cyberMostResponsible = 2 if wave1q32 == "Major IT corporations, like Google or Apple"
replace cyberMostResponsible = 3 if wave1q32 == "The federal government"

lab def cyberresponsible 0 "Individuals and private businesses" ///
1 "Internet service providers" ///
2 "Major IT corporations" ///
3 "The federal government"

lab val cyberMostResponsible cyberresponsible


drop wave1q32 wave1q33 


*************************

lab def threatpossibility 0 "Very unlikely" 1 "Not very likely" 2 "Somewhat likely" ///
3 "Likely" 4 "Very likely"

gen cyberLikelyPowerGrid = .
replace cyberLikelyPowerGrid = 0 if wave1q34_1 == "Very unlikely (less than 1%)"
replace cyberLikelyPowerGrid = 1 if wave1q34_1 == "Not very likely (1 to 24%)"
replace cyberLikelyPowerGrid = 2 if wave1q34_1 == "Somewhat likely (25 to 49%)"
replace cyberLikelyPowerGrid = 3 if wave1q34_1 == "Likely (50 to 75%)"
replace cyberLikelyPowerGrid = 4 if wave1q34_1 == "Very likely (more than 75%)"

gen cyberLikelyMajorCorps = .
replace cyberLikelyMajorCorps = 0 if wave1q34_2 == "Very unlikely (less than 1%)"
replace cyberLikelyMajorCorps = 1 if wave1q34_2 == "Not very likely (1 to 24%)"
replace cyberLikelyMajorCorps = 2 if wave1q34_2 == "Somewhat likely (25 to 49%)"
replace cyberLikelyMajorCorps = 3 if wave1q34_2 == "Likely (50 to 75%)"
replace cyberLikelyMajorCorps = 4 if wave1q34_2 == "Very likely (more than 75%)"

gen cyberLikelyMilitary = .
replace cyberLikelyMilitary = 0 if wave1q34_3 == "Very unlikely (less than 1%)"
replace cyberLikelyMilitary = 1 if wave1q34_3 == "Not very likely (1 to 24%)"
replace cyberLikelyMilitary = 2 if wave1q34_3 == "Somewhat likely (25 to 49%)"
replace cyberLikelyMilitary = 3 if wave1q34_3 == "Likely (50 to 75%)"
replace cyberLikelyMilitary = 4 if wave1q34_3 == "Very likely (more than 75%)"

gen cyberLikelyFederal = .
replace cyberLikelyFederal = 0 if wave1q34_4 == "Very unlikely (less than 1%)"
replace cyberLikelyFederal = 1 if wave1q34_4 == "Not very likely (1 to 24%)"
replace cyberLikelyFederal = 2 if wave1q34_4 == "Somewhat likely (25 to 49%)"
replace cyberLikelyFederal = 3 if wave1q34_4 == "Likely (50 to 75%)"
replace cyberLikelyFederal = 4 if wave1q34_4 == "Very likely (more than 75%)"

gen cyberLikelyVoting = .
replace cyberLikelyVoting = 0 if wave1q34_5 == "Very unlikely (less than 1%)"
replace cyberLikelyVoting = 1 if wave1q34_5 == "Not very likely (1 to 24%)"
replace cyberLikelyVoting = 2 if wave1q34_5 == "Somewhat likely (25 to 49%)"
replace cyberLikelyVoting = 3 if wave1q34_5 == "Likely (50 to 75%)"
replace cyberLikelyVoting = 4 if wave1q34_5 == "Very likely (more than 75%)"

drop wave1q34_*

lab val cyberLikely* threatpossibility

*****

gen democrat3 = .
replace democrat3 = 1 if wave1q15=="Democrat"
replace democrat3 = 0 if wave1q15=="Republican"
replace democrat3 = 0 if wave1q15=="Independent" | wave1q15=="Other"

gen republican3 = .
replace republican3 = 0 if wave1q15=="Democrat"
replace republican3 = 1 if wave1q15=="Republican"
replace republican3 = 0 if wave1q15=="Independent" | wave1q15=="Other"

gen independent3 = .
replace independent3 = 0 if wave1q15=="Democrat"
replace independent3 = 0 if wave1q15=="Republican"
replace independent3 = 1 if wave1q15=="Independent" | wave1q15=="Other"



gen democrat7 = .
replace democrat7 = 1 if wave1q15=="Democrat" | wave1q21 == "Democratic"
replace democrat7 = 0 if wave1q15=="Republican" 
replace democrat7 = 0 if wave1q21=="Republican"
replace democrat7 = 0 if wave1q21=="Independent" & wave1q21 == ""

gen republican7 = .
replace republican7 = 1 if wave1q15=="Republican" | wave1q21 == "Republican"
replace republican7 = 0 if wave1q15=="Democrat" 
replace republican7 = 0 if wave1q21=="Democratic"
replace republican7 = 0 if wave1q21=="Independent" & wave1q21 == ""

gen independent7 = .
replace independent7 = 0 if republican7 == 1
replace independent7 = 0 if democrat7 == 1
replace independent7 = 1 if wave1q21== "Independent" & wave1q21 == ""



*** Attentiveness checks

gen task1attention = 0
replace task1attention = 1 if (wave2q410_1 == wave2q410_2) & ///
							(wave2q410_1 == wave2q410_3) & ///
							(wave2q410_1 == wave2q410_4) & ///
							(wave2q410_1 == wave2q410_5) & ///
							(wave2q410_1 == wave2q410_6) & ///
							wave2q410_1 != ""

replace task1attention = 1 if (wave2q411_1 == wave2q411_2) & ///
							(wave2q411_1 == wave2q411_3) & ///
							(wave2q411_1 == wave2q411_4) & ///
							(wave2q411_1 == wave2q411_5) & ///
							(wave2q411_1 == wave2q411_6) & ///
							wave2q411_1 != ""
							
gen task2attention = 0
replace task2attention = 1 if (wave2q510_1 == wave2q510_2) & ///
							(wave2q510_1 == wave2q510_3) & ///
							(wave2q510_1 == wave2q510_4) & ///
							(wave2q510_1 == wave2q510_5) & ///
							(wave2q510_1 == wave2q510_6) & ///	
							wave2q510_1 != ""

replace task2attention = 1 if (wave2q511_1 == wave2q511_2) & ///
							(wave2q511_1 == wave2q511_3) & ///
							(wave2q511_1 == wave2q511_4) & ///
							(wave2q511_1 == wave2q511_5) & ///
							(wave2q511_1 == wave2q511_6) & ///	
							wave2q511_1 != ""
														
gen task3attention = 0
replace task3attention = 1 if (wave2q610_1 == wave2q610_2) & ///
							(wave2q610_1 == wave2q610_3) & ///
							(wave2q610_1 == wave2q610_4) & ///
							(wave2q610_1 == wave2q610_5) & ///
							(wave2q610_1 == wave2q610_6) & ///	
							wave2q610_1 != ""

replace task3attention = 1 if (wave2q611_1 == wave2q611_2) & ///
							(wave2q611_1 == wave2q611_3) & ///
							(wave2q611_1 == wave2q611_4) & ///
							(wave2q611_1 == wave2q611_5) & ///
							(wave2q611_1 == wave2q611_6) & ///	
							wave2q611_1 != ""
							
gen task4attention = 0
replace task4attention = 1 if (wave2q710_1 == wave2q710_2) & ///
							(wave2q710_1 == wave2q710_3) & ///
							(wave2q710_1 == wave2q710_4) & ///
							(wave2q710_1 == wave2q710_5) & ///
							(wave2q710_1 == wave2q710_6) & ///
							wave2q710_1 != ""

replace task4attention = 1 if (wave2q711_1 == wave2q711_2) & ///
							(wave2q711_1 == wave2q711_3) & ///
							(wave2q711_1 == wave2q711_4) & ///
							(wave2q711_1 == wave2q711_5) & ///
							(wave2q711_1 == wave2q711_6) & ///	
							wave2q711_1 != ""

														
gen task5attention = 0
replace task5attention = 1 if (wave2q810_1 == wave2q810_2) & ///
							(wave2q810_1 == wave2q810_3) & ///
							(wave2q810_1 == wave2q810_4) & ///
							(wave2q810_1 == wave2q810_5) & ///
							(wave2q810_1 == wave2q810_6) & ///
							wave2q810_1 != ""		

replace task5attention = 1 if (wave2q811_1 == wave2q811_2) & ///
							(wave2q811_1 == wave2q811_3) & ///
							(wave2q811_1 == wave2q811_4) & ///
							(wave2q811_1 == wave2q811_5) & ///
							(wave2q811_1 == wave2q811_6) & ///
							wave2q811_1 != ""
							
gen overallattention = 0
replace overallattention = 1 if (task1attention == 1) & ///
							(task2attention == 1) & ///
							(task3attention == 1) & ///
							(task4attention == 1) & ///
							(task5attention == 1)

drop if overallattention == 1
drop overallattention task*attention


*****************************************
* Renaming outcome DVs

gen diplomaticchoice1task1 = .
replace diplomaticchoice1task1 = 1 if wave2q47_1 == "Would support"
replace diplomaticchoice1task1 = 0 if wave2q47_1 == "Would not support"

gen sanctionschoice1task1 = .
replace sanctionschoice1task1 = 1 if wave2q47_2 == "Would support"
replace sanctionschoice1task1 = 0 if wave2q47_2 == "Would not support"

gen cyberespionagechoice1task1 = .
replace cyberespionagechoice1task1 = 1 if wave2q47_3 == "Would support"
replace cyberespionagechoice1task1 = 0 if wave2q47_3 == "Would not support"

gen cyberattackchoice1task1 = .
replace cyberattackchoice1task1 = 1 if wave2q47_4 == "Would support"
replace cyberattackchoice1task1 = 0 if wave2q47_4 == "Would not support"

gen airstrikeschoice1task1 = .
replace airstrikeschoice1task1 = 1 if wave2q47_5 == "Would support"
replace airstrikeschoice1task1 = 0 if wave2q47_5 == "Would not support"

gen intnothingchoice1task1 = .
replace intnothingchoice1task1 = 1 if wave2q47_6 == "Would support"
replace intnothingchoice1task1 = 0 if wave2q47_6 == "Would not support"

***

gen communitysvcchoice1task1 = .
replace communitysvcchoice1task1 = 1 if wave2q48_1 == "Would support"
replace communitysvcchoice1task1 = 0 if wave2q48_1 == "Would not support"

gen finechoice1task1 = .
replace finechoice1task1 = 1 if wave2q48_2 == "Would support"
replace finechoice1task1 = 0 if wave2q48_2 == "Would not support"

gen prisonchoice1task1 = .
replace prisonchoice1task1 = 1 if wave2q48_3 == "Would support"
replace prisonchoice1task1 = 0 if wave2q48_3 == "Would not support"

gen lifesentencechoice1task1 = .
replace lifesentencechoice1task1 = 1 if wave2q48_4 == "Would support"
replace lifesentencechoice1task1 = 0 if wave2q48_4 == "Would not support"

gen deathpenaltychoice1task1 = .
replace deathpenaltychoice1task1 = 1 if wave2q48_5 == "Would support"
replace deathpenaltychoice1task1 = 0 if wave2q48_5 == "Would not support"

gen domnothingchoice1task1 = .
replace domnothingchoice1task1 = 1 if wave2q48_6 == "Would support"
replace domnothingchoice1task1 = 0 if wave2q48_6 == "Would not support"

***

gen diplomaticchoice2task1 = .
replace diplomaticchoice2task1 = 1 if wave2q410_1 == "Would support"
replace diplomaticchoice2task1 = 0 if wave2q410_1 == "Would not support"

gen sanctionschoice2task1 = .
replace sanctionschoice2task1 = 1 if wave2q410_2 == "Would support"
replace sanctionschoice2task1 = 0 if wave2q410_2 == "Would not support"

gen cyberespionagechoice2task1 = .
replace cyberespionagechoice2task1 = 1 if wave2q410_3 == "Would support"
replace cyberespionagechoice2task1 = 0 if wave2q410_3 == "Would not support"

gen cyberattackchoice2task1 = .
replace cyberattackchoice2task1 = 1 if wave2q410_4 == "Would support"
replace cyberattackchoice2task1 = 0 if wave2q410_4 == "Would not support"

gen airstrikeschoice2task1 = .
replace airstrikeschoice2task1 = 1 if wave2q410_5 == "Would support"
replace airstrikeschoice2task1 = 0 if wave2q410_5 == "Would not support"

gen intnothingchoice2task1 = .
replace intnothingchoice2task1 = 1 if wave2q410_6 == "Would support"
replace intnothingchoice2task1 = 0 if wave2q410_6 == "Would not support"

***

gen communitysvcchoice2task1 = .
replace communitysvcchoice2task1 = 1 if wave2q411_1 == "Would support"
replace communitysvcchoice2task1 = 0 if wave2q411_1 == "Would not support"

gen finechoice2task1 = .
replace finechoice2task1 = 1 if wave2q411_2 == "Would support"
replace finechoice2task1 = 0 if wave2q411_2 == "Would not support"

gen prisonchoice2task1 = .
replace prisonchoice2task1 = 1 if wave2q411_3 == "Would support"
replace prisonchoice2task1 = 0 if wave2q411_3 == "Would not support"

gen lifesentencechoice2task1 = .
replace lifesentencechoice2task1 = 1 if wave2q411_4 == "Would support"
replace lifesentencechoice2task1 = 0 if wave2q411_4 == "Would not support"

gen deathpenaltychoice2task1 = .
replace deathpenaltychoice2task1 = 1 if wave2q411_5 == "Would support"
replace deathpenaltychoice2task1 = 0 if wave2q411_5 == "Would not support"

gen domnothingchoice2task1 = .
replace domnothingchoice2task1 = 1 if wave2q411_6 == "Would support"
replace domnothingchoice2task1 = 0 if wave2q411_6 == "Would not support"

drop wave2q47_* wave2q411_* wave2q48_* wave2q410*

*************************************************************

gen diplomaticchoice1task2 = .
replace diplomaticchoice1task2 = 1 if wave2q57_1 == "Would support"
replace diplomaticchoice1task2 = 0 if wave2q57_1 == "Would not support"

gen sanctionschoice1task2 = .
replace sanctionschoice1task2 = 1 if wave2q57_2 == "Would support"
replace sanctionschoice1task2 = 0 if wave2q57_2 == "Would not support"

gen cyberespionagechoice1task2 = .
replace cyberespionagechoice1task2 = 1 if wave2q57_3 == "Would support"
replace cyberespionagechoice1task2 = 0 if wave2q57_3 == "Would not support"

gen cyberattackchoice1task2 = .
replace cyberattackchoice1task2 = 1 if wave2q57_4 == "Would support"
replace cyberattackchoice1task2 = 0 if wave2q57_4 == "Would not support"

gen airstrikeschoice1task2 = .
replace airstrikeschoice1task2 = 1 if wave2q57_5 == "Would support"
replace airstrikeschoice1task2 = 0 if wave2q57_5 == "Would not support"

gen intnothingchoice1task2 = .
replace intnothingchoice1task2 = 1 if wave2q57_6 == "Would support"
replace intnothingchoice1task2 = 0 if wave2q57_6 == "Would not support"

***

gen communitysvcchoice1task2 = .
replace communitysvcchoice1task2 = 1 if wave2q58_1 == "Would support"
replace communitysvcchoice1task2 = 0 if wave2q58_1 == "Would not support"

gen finechoice1task2 = .
replace finechoice1task2 = 1 if wave2q58_2 == "Would support"
replace finechoice1task2 = 0 if wave2q58_2 == "Would not support"

gen prisonchoice1task2 = .
replace prisonchoice1task2 = 1 if wave2q58_3 == "Would support"
replace prisonchoice1task2 = 0 if wave2q58_3 == "Would not support"

gen lifesentencechoice1task2 = .
replace lifesentencechoice1task2 = 1 if wave2q58_4 == "Would support"
replace lifesentencechoice1task2 = 0 if wave2q58_4 == "Would not support"

gen deathpenaltychoice1task2 = .
replace deathpenaltychoice1task2 = 1 if wave2q58_5 == "Would support"
replace deathpenaltychoice1task2 = 0 if wave2q58_5 == "Would not support"

gen domnothingchoice1task2 = .
replace domnothingchoice1task2 = 1 if wave2q58_6 == "Would support"
replace domnothingchoice1task2 = 0 if wave2q58_6 == "Would not support"

***

gen diplomaticchoice2task2 = .
replace diplomaticchoice2task2 = 1 if wave2q510_1 == "Would support"
replace diplomaticchoice2task2 = 0 if wave2q510_1 == "Would not support"

gen sanctionschoice2task2 = .
replace sanctionschoice2task2 = 1 if wave2q510_2 == "Would support"
replace sanctionschoice2task2 = 0 if wave2q510_2 == "Would not support"

gen cyberespionagechoice2task2 = .
replace cyberespionagechoice2task2 = 1 if wave2q510_3 == "Would support"
replace cyberespionagechoice2task2 = 0 if wave2q510_3 == "Would not support"

gen cyberattackchoice2task2 = .
replace cyberattackchoice2task2 = 1 if wave2q510_4 == "Would support"
replace cyberattackchoice2task2 = 0 if wave2q510_4 == "Would not support"

gen airstrikeschoice2task2 = .
replace airstrikeschoice2task2 = 1 if wave2q510_5 == "Would support"
replace airstrikeschoice2task2 = 0 if wave2q510_5 == "Would not support"

gen intnothingchoice2task2 = .
replace intnothingchoice2task2 = 1 if wave2q510_6 == "Would support"
replace intnothingchoice2task2 = 0 if wave2q510_6 == "Would not support"

***

gen communitysvcchoice2task2 = .
replace communitysvcchoice2task2 = 1 if wave2q511_1 == "Would support"
replace communitysvcchoice2task2 = 0 if wave2q511_1 == "Would not support"

gen finechoice2task2 = .
replace finechoice2task2 = 1 if wave2q511_2 == "Would support"
replace finechoice2task2 = 0 if wave2q511_2 == "Would not support"

gen prisonchoice2task2 = .
replace prisonchoice2task2 = 1 if wave2q511_3 == "Would support"
replace prisonchoice2task2 = 0 if wave2q511_3 == "Would not support"

gen lifesentencechoice2task2 = .
replace lifesentencechoice2task2 = 1 if wave2q511_4 == "Would support"
replace lifesentencechoice2task2 = 0 if wave2q511_4 == "Would not support"

gen deathpenaltychoice2task2 = .
replace deathpenaltychoice2task2 = 1 if wave2q511_5 == "Would support"
replace deathpenaltychoice2task2 = 0 if wave2q511_5 == "Would not support"

gen domnothingchoice2task2 = .
replace domnothingchoice2task2 = 1 if wave2q511_6 == "Would support"
replace domnothingchoice2task2 = 0 if wave2q511_6 == "Would not support"

drop wave2q57_* wave2q511_* wave2q58_* wave2q510*

*************************************************************

gen diplomaticchoice1task3 = .
replace diplomaticchoice1task3 = 1 if wave2q67_1 == "Would support"
replace diplomaticchoice1task3 = 0 if wave2q67_1 == "Would not support"

gen sanctionschoice1task3 = .
replace sanctionschoice1task3 = 1 if wave2q67_2 == "Would support"
replace sanctionschoice1task3 = 0 if wave2q67_2 == "Would not support"

gen cyberespionagechoice1task3 = .
replace cyberespionagechoice1task3 = 1 if wave2q67_3 == "Would support"
replace cyberespionagechoice1task3 = 0 if wave2q67_3 == "Would not support"

gen cyberattackchoice1task3 = .
replace cyberattackchoice1task3 = 1 if wave2q67_4 == "Would support"
replace cyberattackchoice1task3 = 0 if wave2q67_4 == "Would not support"

gen airstrikeschoice1task3 = .
replace airstrikeschoice1task3 = 1 if wave2q67_5 == "Would support"
replace airstrikeschoice1task3 = 0 if wave2q67_5 == "Would not support"

gen intnothingchoice1task3 = .
replace intnothingchoice1task3 = 1 if wave2q67_6 == "Would support"
replace intnothingchoice1task3 = 0 if wave2q67_6 == "Would not support"

***

gen communitysvcchoice1task3 = .
replace communitysvcchoice1task3 = 1 if wave2q68_1 == "Would support"
replace communitysvcchoice1task3 = 0 if wave2q68_1 == "Would not support"

gen finechoice1task3 = .
replace finechoice1task3 = 1 if wave2q68_2 == "Would support"
replace finechoice1task3 = 0 if wave2q68_2 == "Would not support"

gen prisonchoice1task3 = .
replace prisonchoice1task3 = 1 if wave2q68_3 == "Would support"
replace prisonchoice1task3 = 0 if wave2q68_3 == "Would not support"

gen lifesentencechoice1task3 = .
replace lifesentencechoice1task3 = 1 if wave2q68_4 == "Would support"
replace lifesentencechoice1task3 = 0 if wave2q68_4 == "Would not support"

gen deathpenaltychoice1task3 = .
replace deathpenaltychoice1task3 = 1 if wave2q68_5 == "Would support"
replace deathpenaltychoice1task3 = 0 if wave2q68_5 == "Would not support"

gen domnothingchoice1task3 = .
replace domnothingchoice1task3 = 1 if wave2q68_6 == "Would support"
replace domnothingchoice1task3 = 0 if wave2q68_6 == "Would not support"

***

gen diplomaticchoice2task3 = .
replace diplomaticchoice2task3 = 1 if wave2q610_1 == "Would support"
replace diplomaticchoice2task3 = 0 if wave2q610_1 == "Would not support"

gen sanctionschoice2task3 = .
replace sanctionschoice2task3 = 1 if wave2q610_2 == "Would support"
replace sanctionschoice2task3 = 0 if wave2q610_2 == "Would not support"

gen cyberespionagechoice2task3 = .
replace cyberespionagechoice2task3 = 1 if wave2q610_3 == "Would support"
replace cyberespionagechoice2task3 = 0 if wave2q610_3 == "Would not support"

gen cyberattackchoice2task3 = .
replace cyberattackchoice2task3 = 1 if wave2q610_4 == "Would support"
replace cyberattackchoice2task3 = 0 if wave2q610_4 == "Would not support"

gen airstrikeschoice2task3 = .
replace airstrikeschoice2task3 = 1 if wave2q610_5 == "Would support"
replace airstrikeschoice2task3 = 0 if wave2q610_5 == "Would not support"

gen intnothingchoice2task3 = .
replace intnothingchoice2task3 = 1 if wave2q610_6 == "Would support"
replace intnothingchoice2task3 = 0 if wave2q610_6 == "Would not support"

***

gen communitysvcchoice2task3 = .
replace communitysvcchoice2task3 = 1 if wave2q611_1 == "Would support"
replace communitysvcchoice2task3 = 0 if wave2q611_1 == "Would not support"

gen finechoice2task3 = .
replace finechoice2task3 = 1 if wave2q611_2 == "Would support"
replace finechoice2task3 = 0 if wave2q611_2 == "Would not support"

gen prisonchoice2task3 = .
replace prisonchoice2task3 = 1 if wave2q611_3 == "Would support"
replace prisonchoice2task3 = 0 if wave2q611_3 == "Would not support"

gen lifesentencechoice2task3 = .
replace lifesentencechoice2task3 = 1 if wave2q611_4 == "Would support"
replace lifesentencechoice2task3 = 0 if wave2q611_4 == "Would not support"

gen deathpenaltychoice2task3 = .
replace deathpenaltychoice2task3 = 1 if wave2q611_5 == "Would support"
replace deathpenaltychoice2task3 = 0 if wave2q611_5 == "Would not support"

gen domnothingchoice2task3 = .
replace domnothingchoice2task3 = 1 if wave2q611_6 == "Would support"
replace domnothingchoice2task3 = 0 if wave2q611_6 == "Would not support"

drop wave2q67_* wave2q611_* wave2q68_* wave2q610*

*************************************************************

gen diplomaticchoice1task4 = .
replace diplomaticchoice1task4 = 1 if wave2q77_1 == "Would support"
replace diplomaticchoice1task4 = 0 if wave2q77_1 == "Would not support"

gen sanctionschoice1task4 = .
replace sanctionschoice1task4 = 1 if wave2q77_2 == "Would support"
replace sanctionschoice1task4 = 0 if wave2q77_2 == "Would not support"

gen cyberespionagechoice1task4 = .
replace cyberespionagechoice1task4 = 1 if wave2q77_3 == "Would support"
replace cyberespionagechoice1task4 = 0 if wave2q77_3 == "Would not support"

gen cyberattackchoice1task4 = .
replace cyberattackchoice1task4 = 1 if wave2q77_4 == "Would support"
replace cyberattackchoice1task4 = 0 if wave2q77_4 == "Would not support"

gen airstrikeschoice1task4 = .
replace airstrikeschoice1task4 = 1 if wave2q77_5 == "Would support"
replace airstrikeschoice1task4 = 0 if wave2q77_5 == "Would not support"

gen intnothingchoice1task4 = .
replace intnothingchoice1task4 = 1 if wave2q77_6 == "Would support"
replace intnothingchoice1task4 = 0 if wave2q77_6 == "Would not support"

***

gen communitysvcchoice1task4 = .
replace communitysvcchoice1task4 = 1 if wave2q78_1 == "Would support"
replace communitysvcchoice1task4 = 0 if wave2q78_1 == "Would not support"

gen finechoice1task4 = .
replace finechoice1task4 = 1 if wave2q78_2 == "Would support"
replace finechoice1task4 = 0 if wave2q78_2 == "Would not support"

gen prisonchoice1task4 = .
replace prisonchoice1task4 = 1 if wave2q78_3 == "Would support"
replace prisonchoice1task4 = 0 if wave2q78_3 == "Would not support"

gen lifesentencechoice1task4 = .
replace lifesentencechoice1task4 = 1 if wave2q78_4 == "Would support"
replace lifesentencechoice1task4 = 0 if wave2q78_4 == "Would not support"

gen deathpenaltychoice1task4 = .
replace deathpenaltychoice1task4 = 1 if wave2q78_5 == "Would support"
replace deathpenaltychoice1task4 = 0 if wave2q78_5 == "Would not support"

gen domnothingchoice1task4 = .
replace domnothingchoice1task4 = 1 if wave2q78_6 == "Would support"
replace domnothingchoice1task4 = 0 if wave2q78_6 == "Would not support"

***

gen diplomaticchoice2task4 = .
replace diplomaticchoice2task4 = 1 if wave2q710_1 == "Would support"
replace diplomaticchoice2task4 = 0 if wave2q710_1 == "Would not support"

gen sanctionschoice2task4 = .
replace sanctionschoice2task4 = 1 if wave2q710_2 == "Would support"
replace sanctionschoice2task4 = 0 if wave2q710_2 == "Would not support"

gen cyberespionagechoice2task4 = .
replace cyberespionagechoice2task4 = 1 if wave2q710_3 == "Would support"
replace cyberespionagechoice2task4 = 0 if wave2q710_3 == "Would not support"

gen cyberattackchoice2task4 = .
replace cyberattackchoice2task4 = 1 if wave2q710_4 == "Would support"
replace cyberattackchoice2task4 = 0 if wave2q710_4 == "Would not support"

gen airstrikeschoice2task4 = .
replace airstrikeschoice2task4 = 1 if wave2q710_5 == "Would support"
replace airstrikeschoice2task4 = 0 if wave2q710_5 == "Would not support"

gen intnothingchoice2task4 = .
replace intnothingchoice2task4 = 1 if wave2q710_6 == "Would support"
replace intnothingchoice2task4 = 0 if wave2q710_6 == "Would not support"

***

gen communitysvcchoice2task4 = .
replace communitysvcchoice2task4 = 1 if wave2q711_1 == "Would support"
replace communitysvcchoice2task4 = 0 if wave2q711_1 == "Would not support"

gen finechoice2task4 = .
replace finechoice2task4 = 1 if wave2q711_2 == "Would support"
replace finechoice2task4 = 0 if wave2q711_2 == "Would not support"

gen prisonchoice2task4 = .
replace prisonchoice2task4 = 1 if wave2q711_3 == "Would support"
replace prisonchoice2task4 = 0 if wave2q711_3 == "Would not support"

gen lifesentencechoice2task4 = .
replace lifesentencechoice2task4 = 1 if wave2q711_4 == "Would support"
replace lifesentencechoice2task4 = 0 if wave2q711_4 == "Would not support"

gen deathpenaltychoice2task4 = .
replace deathpenaltychoice2task4 = 1 if wave2q711_5 == "Would support"
replace deathpenaltychoice2task4 = 0 if wave2q711_5 == "Would not support"

gen domnothingchoice2task4 = .
replace domnothingchoice2task4 = 1 if wave2q711_6 == "Would support"
replace domnothingchoice2task4 = 0 if wave2q711_6 == "Would not support"

drop wave2q77_* wave2q711_* wave2q78_* wave2q710*

*************************************************************

gen diplomaticchoice1task5 = .
replace diplomaticchoice1task5 = 1 if wave2q87_1 == "Would support"
replace diplomaticchoice1task5 = 0 if wave2q87_1 == "Would not support"

gen sanctionschoice1task5 = .
replace sanctionschoice1task5 = 1 if wave2q87_2 == "Would support"
replace sanctionschoice1task5 = 0 if wave2q87_2 == "Would not support"

gen cyberespionagechoice1task5 = .
replace cyberespionagechoice1task5 = 1 if wave2q87_3 == "Would support"
replace cyberespionagechoice1task5 = 0 if wave2q87_3 == "Would not support"

gen cyberattackchoice1task5 = .
replace cyberattackchoice1task5 = 1 if wave2q87_4 == "Would support"
replace cyberattackchoice1task5 = 0 if wave2q87_4 == "Would not support"

gen airstrikeschoice1task5 = .
replace airstrikeschoice1task5 = 1 if wave2q87_5 == "Would support"
replace airstrikeschoice1task5 = 0 if wave2q87_5 == "Would not support"

gen intnothingchoice1task5 = .
replace intnothingchoice1task5 = 1 if wave2q87_6 == "Would support"
replace intnothingchoice1task5 = 0 if wave2q87_6 == "Would not support"

***

gen communitysvcchoice1task5 = .
replace communitysvcchoice1task5 = 1 if wave2q88_1 == "Would support"
replace communitysvcchoice1task5 = 0 if wave2q88_1 == "Would not support"

gen finechoice1task5 = .
replace finechoice1task5 = 1 if wave2q88_2 == "Would support"
replace finechoice1task5 = 0 if wave2q88_2 == "Would not support"

gen prisonchoice1task5 = .
replace prisonchoice1task5 = 1 if wave2q88_3 == "Would support"
replace prisonchoice1task5 = 0 if wave2q88_3 == "Would not support"

gen lifesentencechoice1task5 = .
replace lifesentencechoice1task5 = 1 if wave2q88_4 == "Would support"
replace lifesentencechoice1task5 = 0 if wave2q88_4 == "Would not support"

gen deathpenaltychoice1task5 = .
replace deathpenaltychoice1task5 = 1 if wave2q88_5 == "Would support"
replace deathpenaltychoice1task5 = 0 if wave2q88_5 == "Would not support"

gen domnothingchoice1task5 = .
replace domnothingchoice1task5 = 1 if wave2q88_6 == "Would support"
replace domnothingchoice1task5 = 0 if wave2q88_6 == "Would not support"

***

gen diplomaticchoice2task5 = .
replace diplomaticchoice2task5 = 1 if wave2q810_1 == "Would support"
replace diplomaticchoice2task5 = 0 if wave2q810_1 == "Would not support"

gen sanctionschoice2task5 = .
replace sanctionschoice2task5 = 1 if wave2q810_2 == "Would support"
replace sanctionschoice2task5 = 0 if wave2q810_2 == "Would not support"

gen cyberespionagechoice2task5 = .
replace cyberespionagechoice2task5 = 1 if wave2q810_3 == "Would support"
replace cyberespionagechoice2task5 = 0 if wave2q810_3 == "Would not support"

gen cyberattackchoice2task5 = .
replace cyberattackchoice2task5 = 1 if wave2q810_4 == "Would support"
replace cyberattackchoice2task5 = 0 if wave2q810_4 == "Would not support"

gen airstrikeschoice2task5 = .
replace airstrikeschoice2task5 = 1 if wave2q810_5 == "Would support"
replace airstrikeschoice2task5 = 0 if wave2q810_5 == "Would not support"

gen intnothingchoice2task5 = .
replace intnothingchoice2task5 = 1 if wave2q810_6 == "Would support"
replace intnothingchoice2task5 = 0 if wave2q810_6 == "Would not support"

***

gen communitysvcchoice2task5 = .
replace communitysvcchoice2task5 = 1 if wave2q811_1 == "Would support"
replace communitysvcchoice2task5 = 0 if wave2q811_1 == "Would not support"

gen finechoice2task5 = .
replace finechoice2task5 = 1 if wave2q811_2 == "Would support"
replace finechoice2task5 = 0 if wave2q811_2 == "Would not support"

gen prisonchoice2task5 = .
replace prisonchoice2task5 = 1 if wave2q811_3 == "Would support"
replace prisonchoice2task5 = 0 if wave2q811_3 == "Would not support"

gen lifesentencechoice2task5 = .
replace lifesentencechoice2task5 = 1 if wave2q811_4 == "Would support"
replace lifesentencechoice2task5 = 0 if wave2q811_4 == "Would not support"

gen deathpenaltychoice2task5 = .
replace deathpenaltychoice2task5 = 1 if wave2q811_5 == "Would support"
replace deathpenaltychoice2task5 = 0 if wave2q811_5 == "Would not support"

gen domnothingchoice2task5 = .
replace domnothingchoice2task5 = 1 if wave2q811_6 == "Would support"
replace domnothingchoice2task5 = 0 if wave2q811_6 == "Would not support"

drop wave2q87_* wave2q811_* wave2q88_* wave2q810*

****

lab def supportnosupport 1 "Would support" 0 "Would not support"

lab val diplomaticchoice* supportnosupport
lab val sanctionschoice* supportnosupport
lab val cyberespionage* supportnosupport
lab val cyberattack* supportnosupport
lab val airstrikes* supportnosupport
lab val intnothingchoice* supportnosupport

lab val communitysvcchoice* supportnosupport
lab val finechoice* supportnosupport
lab val prisonchoice* supportnosupport
lab val lifesentence* supportnosupport
lab val deathpenaltychoice* supportnosupport
lab val domnothingchoice* supportnosupport

* renaming conjoint DVs to interpetable versions

rename wave2q43_1 confidentchoice1task1
rename wave2q43_4 confidentchoice2task1
rename wave2q45_1 severechoice1task1
rename wave2q45_4 severechoice2task1

rename wave2q53_1 confidentchoice1task2
rename wave2q53_4 confidentchoice2task2
rename wave2q55_1 severechoice1task2
rename wave2q55_4 severechoice2task2

rename wave2q63_1 confidentchoice1task3
rename wave2q63_4 confidentchoice2task3
rename wave2q65_1 severechoice1task3
rename wave2q65_4 severechoice2task3

rename wave2q73_1 confidentchoice1task4
rename wave2q73_4 confidentchoice2task4
rename wave2q75_1 severechoice1task4
rename wave2q75_4 severechoice2task4

rename wave2q83_1 confidentchoice1task5
rename wave2q83_4 confidentchoice2task5
rename wave2q85_1 severechoice1task5
rename wave2q85_4 severechoice2task5

							
order confidentchoice1task1 confidentchoice2task1 ///
 severechoice1task1 severechoice2task1  ///
confidentchoice1task2 confidentchoice2task2  ///
severechoice1task2 severechoice2task2  ///
confidentchoice1task3 confidentchoice2task3  ///
severechoice1task3 severechoice2task3  ///
confidentchoice1task4 confidentchoice2task4  ///
severechoice1task4 severechoice2task4  ///
confidentchoice1task5 confidentchoice2task5  ///
severechoice1task5 severechoice2task5, before(f11)

order caseid age female college white democrat3 republican3 ///
independent3 democrat7 republican7, first

drop  wave2startdate wave2enddate ///
  wave2recordeddate wave2q21 wave2q23 wave2q24 ///
 wave2q3*  mturkcode  wave1startdate ///
 wave1enddate    ///
  wave1consentform wave1q4 wave1q5 wave1q6 ///
 wave1q9 wave1q11 wave1q26 wave1q13 wave1q15 wave1q19 wave1q17 wave1q21 ///
 wave1q23 wave1q25 wave1mturkcode wave2q22 wave2age wave2female wave2college

 
 * rename each experiment's traits into interpretable versions, 
 * drop needless variables
 
drop f11 f12 f13 f14 f15 f16 f17 f18 f19 f110
drop f21 f22 f23 f24 f25 f26 f27 f28 f29 f210
drop f31 f32 f33 f34 f35 f36 f37 f38 f39 f310
drop f41 f42 f43 f44 f45 f46 f47 f48 f49 f410
drop f51 f52 f53 f54 f55 f56 f57 f58 f59 f510


rename f111 f_targetchoice1task1
rename f112 f_economicchoice1task1
rename f113 f_deathchoice1task1
rename f114 f_confidencechoice1task1
rename f115 f_aggressortypechoice1task1
rename f116 f_aggressororiginchoice1task1
rename f117 f_purposechoice1task1
rename f118 f_indconcurchoice1task1
rename f119 f_policymakertypechoice1task1
rename f1110 f_policymakerconcurchoice1task1
rename f121 f_targetchoice2task1
rename f122 f_economicchoice2task1
rename f123 f_deathchoice2task1
rename f124 f_confidencechoice2task1
rename f125 f_aggressortypechoice2task1
rename f126 f_aggressororiginchoice2task1
rename f127 f_purposechoice2task1
rename f128 f_indconcurchoice2task1
rename f129 f_policymakertypechoice2task1
rename f1210 f_policymakerconcurchoice2task1

rename f211 f_targetchoice1task2
rename f212 f_economicchoice1task2
rename f213 f_deathchoice1task2
rename f214 f_confidencechoice1task2
rename f215 f_aggressortypechoice1task2
rename f216 f_aggressororiginchoice1task2
rename f217 f_purposechoice1task2
rename f218 f_indconcurchoice1task2
rename f219 f_policymakertypechoice1task2
rename f2110 f_policymakerconcurchoice1task2
rename f221 f_targetchoice2task2
rename f222 f_economicchoice2task2
rename f223 f_deathchoice2task2
rename f224 f_confidencechoice2task2
rename f225 f_aggressortypechoice2task2
rename f226 f_aggressororiginchoice2task2
rename f227 f_purposechoice2task2
rename f228 f_indconcurchoice2task2
rename f229 f_policymakertypechoice2task2
rename f2210 f_policymakerconcurchoice2task2

rename f311 f_targetchoice1task3
rename f312 f_economicchoice1task3
rename f313 f_deathchoice1task3
rename f314 f_confidencechoice1task3
rename f315 f_aggressortypechoice1task3
rename f316 f_aggressororiginchoice1task3
rename f317 f_purposechoice1task3
rename f318 f_indconcurchoice1task3
rename f319 f_policymakertypechoice1task3
rename f3110 f_policymakerconcurchoice1task3
rename f321 f_targetchoice2task3
rename f322 f_economicchoice2task3
rename f323 f_deathchoice2task3
rename f324 f_confidencechoice2task3
rename f325 f_aggressortypechoice2task3
rename f326 f_aggressororiginchoice2task3
rename f327 f_purposechoice2task3
rename f328 f_indconcurchoice2task3
rename f329 f_policymakertypechoice2task3
rename f3210 f_policymakerconcurchoice2task3

rename f411 f_targetchoice1task4
rename f412 f_economicchoice1task4
rename f413 f_deathchoice1task4
rename f414 f_confidencechoice1task4
rename f415 f_aggressortypechoice1task4
rename f416 f_aggressororiginchoice1task4
rename f417 f_purposechoice1task4
rename f418 f_indconcurchoice1task4
rename f419 f_policymakertypechoice1task4
rename f4110 f_policymakerconcurchoice1task4
rename f421 f_targetchoice2task4
rename f422 f_economicchoice2task4
rename f423 f_deathchoice2task4
rename f424 f_confidencechoice2task4
rename f425 f_aggressortypechoice2task4
rename f426 f_aggressororiginchoice2task4
rename f427 f_purposechoice2task4
rename f428 f_indconcurchoice2task4
rename f429 f_policymakertypechoice2task4
rename f4210 f_policymakerconcurchoice2task4

rename f511 f_targetchoice1task5
rename f512 f_economicchoice1task5
rename f513 f_deathchoice1task5
rename f514 f_confidencechoice1task5
rename f515 f_aggressortypechoice1task5
rename f516 f_aggressororiginchoice1task5
rename f517 f_purposechoice1task5
rename f518 f_indconcurchoice1task5
rename f519 f_policymakertypechoice1task5
rename f5110 f_policymakerconcurchoice1task5
rename f521 f_targetchoice2task5
rename f522 f_economicchoice2task5
rename f523 f_deathchoice2task5
rename f524 f_confidencechoice2task5
rename f525 f_aggressortypechoice2task5
rename f526 f_aggressororiginchoice2task5
rename f527 f_purposechoice2task5
rename f528 f_indconcurchoice2task5
rename f529 f_policymakertypechoice2task5
rename f5210 f_policymakerconcurchoice2task5 

 
order threatKorea threatCyber threatTerrorism threatIran threatChina ///
threatFinancial threatMuslim threatRussia threatEbola threatRefugees ///
threatChinaNeighbor threatClimate cyberForeign cyberUSA cyberPersonal ///
cyberPrepared cyberMostResponsible cyberLikelyPowerGrid cyberLikelyMajorCorps ///
cyberLikelyMilitary cyberLikelyFederal cyberLikelyVoting, before(confidentchoice1task1)

*rename *task* *_*

rename f_* *


reshape long targetchoice1task targetchoice2task economicchoice1task economicchoice2task ///
deathchoice1task deathchoice2task confidencechoice1task confidencechoice2task ///
aggressortypechoice1task aggressortypechoice2task aggressororiginchoice1task ///
aggressororiginchoice2task purposechoice1task purposechoice2task indconcurchoice1task ///
indconcurchoice2task policymakertypechoice1task policymakertypechoice2task ///
policymakerconcurchoice1task policymakerconcurchoice2task ///
confidentchoice1task confidentchoice2task severechoice1task severechoice2task ///
diplomaticchoice1task sanctionschoice1task cyberespionagechoice1task cyberattackchoice1task ///
airstrikeschoice1task  intnothingchoice1task communitysvcchoice1task finechoice1task ///
prisonchoice1task lifesentencechoice1task deathpenaltychoice1task domnothingchoice1task ///
diplomaticchoice2task sanctionschoice2task cyberespionagechoice2task cyberattackchoice2task ///
airstrikeschoice2task  intnothingchoice2task communitysvcchoice2task finechoice2task ///
prisonchoice2task lifesentencechoice2task deathpenaltychoice2task domnothingchoice2task ///
, i(caseid) j(ptask)

rename *task *

rename p task

reshape long targetchoice economicchoice deathchoice confidencechoice aggressortypechoice ///
aggressororiginchoice purposechoice indconcurchoice policymakertypechoice ///
policymakerconcurchoice confidentchoice severechoice diplomaticchoice sanctionschoice ///
cyberespionagechoice cyberattackchoice airstrikeschoice intnothingchoice communitysvcchoice ///
finechoice prisonchoice lifesentencechoice deathpenaltychoice domnothingchoice, i(caseid task) j(pchoice)

rename *choice *
rename p choice

drop if target == ""

******
* Recode treatment variables into interpretable versions 

gen target2 = .
replace target2 = 0 if target == "Large U.S. corporations"
replace target2 = 1 if target == "The U.S. banking and financial system"
replace target2 = 2 if target == "Hospitals across the United States"
replace target2 = 3 if target == "The U.S. power grid"
replace target2 = 4 if target == "The U.S. military's computer networks"

lab def targetlab 0 "Large U.S. corporations" 1  "The U.S. banking and financial system" ///
2 "Hospitals across the United States" 3 "The U.S. power grid" 4 "The U.S. military's computer networks"

lab val target2 targetlab
drop target
rename target2 target

***

gen economic2 = .
replace economic2 = 0 if economic == "Minimal"
replace economic2 = 1 if economic == "A few million dollars"
replace economic2 = 2 if economic == "Tens of millions of dollars"
replace economic2 = 3 if economic == "Billions of dollars"

lab def economiclab 0 "Minimal" 1 "A few million dollars" 2 "Tens of millions of dollars" ///
3 "Billions of dollars"

lab val economic2 economiclab
drop economic
rename economic2 economic

***

gen death2 = .
replace death2 = 0 if death == "No"
replace death2 = 1 if death == "One person"
replace death2 = 2 if death == "Dozens of people"
replace death2 = 3 if death == "Hundreds of people"

lab def deathlab 0 "No" 1 "One person" 2 "Dozens of people" 3 "Hundreds of people"
lab val death2 deathlab
drop death
rename death2 death

***

gen confidence2 = .

replace confidence2 = 0 if confidence == "Somewhat certain"
replace confidence2 = 1 if confidence == "Highly confident but not certain"
replace confidence2 = 2 if confidence == "Unanimously confident"

lab def confidencelab 0 "Somewhat certain" 1 "Highly confident" 2 "Unanimously confident"

lab val confidence2 confidencelab
drop confidence
rename confidence2 confidence

***

gen aggressortype2 = .

replace aggressortype2 = 0 if aggressortype == "An individual"
replace aggressortype2 = 1 if aggressortype == "A group of civilian hackers"
replace aggressortype2 = 2 if aggressortype == "A group of terrorists"
replace aggressortype2 = 3 if aggressortype == "A government agency"

lab def aggressortypelab 0 "An individual" 1 "A group of civilian hackers" ///
2 "A group of terrorists" 3 "A government agency"

lab val aggressortype2 aggressortypelab
drop aggressortype
rename aggressortype2 aggressortype

***

gen aggressororigin2 = .

replace aggressororigin2 = 0 if aggressororigin == "Israel"
replace aggressororigin2 = 1 if aggressororigin == "Iran"
replace aggressororigin2 = 2 if aggressororigin == "North Korea"
replace aggressororigin2 = 3 if aggressororigin == "Russia"
replace aggressororigin2 = 4 if aggressororigin == "China"
replace aggressororigin2 = 5 if aggressororigin == "the United States"


lab def aggressororiginlab 0 "Israel" 1 "Iran" 2 "North Korea" 3 "Russia" ///
4 "China" 5 "the United States"


lab val aggressororigin2 aggressororiginlab
drop aggressororigin
rename aggressororigin2 aggressororigin

***

gen purpose2 = .

replace purpose2 = 0 if purpose == "No clear motivation"
replace purpose2 = 1 if purpose == "Stealing sensitive information"
replace purpose2 = 2 if purpose == "Retaliating for specific U.S. policies"
replace purpose2 = 3 if purpose == "Disrupting American society generally"

lab def purposelab 0 "No clear motivation" 1 "Stealing sensitive information" ///
2 "Retaliating for specific U.S. policies" 3 "Disrupting American society generally" 

lab val purpose2 purposelab
drop purpose
rename purpose2 purpose

***

gen indconcur2 = .

replace indconcur2 = 0 if indconcur == "mostly reject it"
replace indconcur2 = 1 if indconcur == "have mixed views about it"
replace indconcur2 = 2 if indconcur == "mostly agree with it"

lab def indconcurlab 0 "mostly reject it" 1 "have mixed views about it" ///
2 "mostly agree with it" 

lab val indconcur2 indconcurlab
drop indconcur
rename indconcur2 indconcur

***

gen policymakertype2 = .

replace policymakertype2 = 0 if policymakertype == "Secretary of Defense Shanahan"
replace policymakertype2 = 1 if policymakertype == "President Trump"

lab def policymakertypelab 0 "Shanahan" 1 "Trump" 

lab val policymakertype2 policymakertypelab
drop policymakertype
rename policymakertype2 policymakertype

***

gen policymakerconcur2 = .

replace policymakerconcur2 = 0 if policymakerconcur == "disputed it"
replace policymakerconcur2 = 1 if policymakerconcur == "refused to comment"
replace policymakerconcur2 = 2 if policymakerconcur == "endorsed it"

lab def policymakerconcurlab 0 "disputed it" 1 "refused to comment" 2 "endorsed it"

lab val policymakerconcur2 policymakerconcurlab
drop policymakerconcur
rename policymakerconcur2 policymakerconcur


*** 
* Generate underlying propensities

egen intlwarmth = rowmean(thermRUS thermGBR thermPRC thermIND thermFRA ///
thermPRK thermDEU thermJPN thermIRN thermISR thermVNM thermCAN thermBRA)

gen warmth = . 
replace warmth = thermISR if aggressororigin == 0
replace warmth = thermIRN if aggressororigin == 1
replace warmth = thermPRK if aggressororigin == 2
replace warmth = thermRUS if aggressororigin == 3
replace warmth = thermPRC if aggressororigin == 4

gen threat = .
replace threat = threatCyberIran if aggressororigin == 1
replace threat = threatCyberKorea if aggressororigin == 2
replace threat = threatCyberRussia if aggressororigin == 3
replace threat = threatCyberChina if aggressororigin == 4


****
* Generate unified scale for ordinal outcome variables (ologit)
* Generate divided scale for ordinal outcome variables (ologit by type)

* highest score on either 

gen unifieddv = .
replace unifieddv = 0 if domnothing == 1 | intnothing == 1
replace unifieddv = 1 if diplomatic == 1 | communitysvc == 1
replace unifieddv = 2 if sanctions == 1 | fine == 1
replace unifieddv = 3 if cyberespionage == 1 | prison == 1
replace unifieddv = 4 if cyberattack == 1 | lifesentence == 1
replace unifieddv = 5 if airstrikes == 1 | deathpenalty == 1

gen intdv = .
replace intdv = 0 if intnothing == 1 
replace intdv = 1 if diplomatic == 1
replace intdv = 2 if sanctions == 1
replace intdv = 3 if cyberespionage == 1
replace intdv = 4 if cyberattack == 1
replace intdv = 5 if airstrikes == 1

gen domdv = .
replace domdv = 0 if domnothing == 1
replace domdv = 1 if communitysvc == 1
replace domdv = 2 if fine == 1
replace domdv = 3 if prison == 1
replace domdv = 4 if lifesentence == 1
replace domdv = 5 if deathpenalty == 1

cd "$path/Data/"
save "TheCyber2019AnalysisData.dta", replace
